/**
 * 
 */

dojo.require("dijit.dijit"); // loads the optimized dijit layer
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.TitlePane");
dojo.require("dijit.Calendar");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Form");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.DropDownButton");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.MultiSelect");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.form.NumberTextBox");
dojo.require("dijit.form.RadioButton");
dojo.require("dijit.form.Select");
dojo.require("dijit.form.SimpleTextarea");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Textarea");
dojo.require("dijit.form.TimeTextBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.Menu");
dojo.require("dijit.Tooltip");
dojo.require("dojo.date.locale");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojo.fx");
dojo.require("dojox.data.QueryReadStore");
dojo.require("dojox.grid.DataGrid");
dojo.require("dojox.grid.cells.dijit");
dojo.require("dojox.layout.ContentPane");
dojo.require("dojox.json.ref");
dojo.require("dojox.validate.regexp");
dojo.require("dojo.parser");

function galaxytool_general_init() {
	//dojo.byId("topPanel").style.top       = "0px";
	//dojo.byId("bottomPanel").style.bottom = "0px";
}

dojo.ready(galaxytool_general_init);

dojo.ready(function(){
	dojo.query(".startsHidden")
		.style("opacity", 100)
		.removeClass("startsHidden")
	;
})


function galaxytool_check_for_version() {
	dojo.fx.wipeIn({ node: dojo.byId("updateArea") }).play();
	dijit.byId("updateAreaContent").set("href","ajax/ajax_updatecheck.php");
	window.setTimeout("galaxytool_hide_updateinfo()", 10000);
}

function galaxytool_hide_updateinfo() {
	dojo.fx.wipeOut({ node: dojo.byId("updateArea") }).play();
}


function galaxytool_compare_coordinates (a,b) {
	var part_a = a.split(":");
	var part_b = b.split(":");
	if (part_a.length != 3 || part_b.length != 3) return 0;
	
	a = parseInt(part_a[0]) * 100000 + parseInt(part_a[1]) * 100 + parseInt(part_a[2]);
	b = parseInt(part_b[0]) * 100000 + parseInt(part_b[1]) * 100 + parseInt(part_b[2]);
	
   if (a < b){
     return -1;
   } else if (a > b) {
     return 1;
   } else {
     return 0;
   }
}

function galaxytool_compare_integer (a,b) {
   if (parseInt(a) < parseInt(b)){
     return -1;
   } else if (parseInt(a) > parseInt(b)) {
     return 1;
   } else {
     return 0;
   }
}

function galaxytool_compare_float (a,b) {
   if (parseFloat(a) < parseFloat(b)){
     return -1;
   } else if (parseFloat(a) > parseFloat(b)) {
     return 1;
   } else {
     return 0;
   }
}

function NumberFormat(nStr) {
	nStr += '';
	x = nStr.split(',');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}

function get_player_status_string(banned,vacation,noob,inactive,long_inactive,outlaw) {
	var status = "";
	if (banned != "false") {
		status += "<span class=\"banned\">"+TEXT_PLAYER_BANNED+"</span>";
	}
	if (vacation != "false") {
		status += "<span class=\"vacation\">"+TEXT_PLAYER_VACATION_MODE+"</span>";
	}
	if (noob != "false") {
		status += "<span class=\"noob\">"+TEXT_PLAYER_NOOB+"</span>";
	}
	if (inactive != "false") {
		status += "<span class=\"inactive\">"+TEXT_PLAYER_INACTIVE+"</span>";
	}
	if (long_inactive != "false") {
		status += "<span class=\"longinactive\">"+TEXT_PLAYER_LONG_INACTIVE+"</span>";
	}
	if (outlaw != "false") {
		status += "<span class=\"outlaw\">"+TEXT_PLAYER_OUTLAW+"</span>";
	}
	return status;
}